package com.zf.lease.domain;

import java.util.Date;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.zf.apartment.domain.Room;
import com.zf.common.annotation.Excel;
import com.zf.common.core.domain.BaseEntity;
import com.zf.system.domain.Customer;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

/**
 * 契约对象 contract
 *
 * @author rxf
 * @date 2024-09-28
 */
@TableName(resultMap = "com.zf.lease.mapper.ContractMapper.ContractResult")
public class Contract extends BaseEntity{
        private static final long serialVersionUID = 1L;

        /** 契约ID */
        @TableId(value = "contract_id",type = IdType.AUTO)
        private Long contractId;
        /** 客户ID */
        private Long customerId;

        /** 房间ID */
        private Long roomId;

        /** 客户对象 */
        @TableField(exist = false)
        private Customer customer;

        /** 房间对象 */
        @TableField(exist = false)
        private Room room;
        /** 契约类型 */
        @Excel(name = "契约类型")
        private String contractType;

        /** 开始时间 */
        @JsonFormat(pattern = "yyyy-MM-dd")
        @Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd")
        private Date startDate;

        /** 结束时间 */
        @JsonFormat(pattern = "yyyy-MM-dd")
        @Excel(name = "结束时间", width = 30, dateFormat = "yyyy-MM-dd")
        private Date endDate;
        /**
         * 删除标志（0代表存在 1代表删除）
         */
        private Integer delFlag;

        public Integer getDelFlag() {
            return delFlag;
        }

        public void setDelFlag(Integer delFlag) {
            this.delFlag = delFlag;
        }

        public void setContractId(Long contractId)
    {
        this.contractId = contractId;
    }

        public Long getContractId()
        {
            return contractId;
        }
        public void setContractType(String contractType)
        {
            this.contractType = contractType;
        }

        public String getContractType()
        {
            return contractType;
        }
        public void setStartDate(Date startDate)
        {
            this.startDate = startDate;
        }

        public Date getStartDate()
        {
            return startDate;
        }
        public void setEndDate(Date endDate)
        {
            this.endDate = endDate;
        }

        public Date getEndDate()
        {
            return endDate;
        }

        public Long getCustomerId() {
            return customerId;
        }

        public void setCustomerId(Long customerId) {
            this.customerId = customerId;
        }

        public Long getRoomId() {
            return roomId;
        }

        public void setRoomId(Long roomId) {
            this.roomId = roomId;
        }

        public Customer getCustomer() {
            return customer;
        }

        public void setCustomer(Customer customer) {
            this.customer = customer;
        }

        public Room getRoom() {
            return room;
        }

        public void setRoom(Room room) {
            this.room = room;
        }
        // 新增的 getRoomName 方法
        public String getRoomName() {
            return room != null ? room.getRoomName() : null;
        }

        // 新增的 getCustomerName 方法
        public String getCustomerName() {
            return customer != null ? customer.getCustomerName() : null;
        }

        // 为了支持可能的设置操作，我们也添加相应的 setter 方法
        public void setRoomName(String roomName) {
            if (room == null) {
                room = new Room();
            }
            room.setRoomName(roomName);
        }

        public void setCustomerName(String customerName) {
            if (customer == null) {
                customer = new Customer();
            }
            customer.setCustomerName(customerName);
        }

        @Override
        public String toString() {
            return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                    .append("contractId", getContractId())
                    .append("contractType", getContractType())
                    .append("startDate", getStartDate())
                    .append("endDate", getEndDate())
                    .append("customerId", getCustomerId())
                    .append("roomId", getRoomId())
                    .append("customerName", getCustomerName())
                    .append("roomName", getRoomName())
                    .toString();
        }
}